package test_achieve.web.scenes;
import constant.Pm;
import cucumber.api.java.en.Given;
import test_achieve.web.Oneself;
import test_achieve.web.OrderMain;
import test_achieve.Devices;

/**
 * Created by chenkuo on 2017/10/23.
 */
public class Basic {

    /**订单基础的一些场景封装*/

    /**前置：无
     * 步骤：切成城市*/

    @Given("^w登录并切换城市：(.+)：(.+)$")
    public void w登录并切换城市(String username,String city) throws Throwable {
        Devices device = new Devices();
        OrderMain webmain = new OrderMain();
        username = username == null ? "15501213529" : username;
        device.openBrowser();
        webmain.wLogInEnterInterface(username);
        Oneself me = new Oneself();
        me.w切换城市(city);
    }

    /**前置：订单输入界面
     * 步骤：输入寄件人与收件人信息*/

    @Given("^w输入寄件人信息与收件人信息"+Pm.p6)
    public void w输入寄件人信息与收件人信息(String sendAdress,String sendName,String sendMobile,String receiveAddress,String receiveName,String receiveMobile) throws Throwable {
        OrderMain webmain = new OrderMain();
        sendAdress = sendAdress == null ? "昌平西山口" : sendAdress;
        sendName = sendName == null ? "路飞" : sendName;
        sendMobile = sendMobile == null ? "15501213579" : sendMobile;
        receiveAddress = receiveAddress == null ? "西二旗" : receiveAddress;
        receiveName = receiveName == null ? "山治" : receiveName;
        receiveMobile = receiveMobile == null ? "15501213579" : receiveMobile;
        webmain.wInput_sender(sendAdress);
        webmain.wEnterSenderName(sendName);
        webmain.wEnterSenderCellPhoneNumber(sendMobile);
        webmain.wEnterRecipientAddress(receiveAddress);
        webmain.wEnterRecipientName(receiveName);
        webmain.wEnterRecipientMobile(receiveMobile);
    }

    @Given("^w输入寄件人信息与收件人信息"+Pm.p2)
    public void w输入寄件人信息与收件人信息(String sendAdress,String receiveAddress) throws Throwable {
        w输入寄件人信息与收件人信息( sendAdress, null, null, receiveAddress, null, null);
    }

    /**前置：订单输入界面
     * 步骤：输入物品名称*/

    @Given("^w输入物品信息"+ Pm.p3)
    public void w输入物品信息(String weights,String goodsName,String remark) throws Throwable {
        OrderMain webmain = new OrderMain();
        webmain.wEnterItemWeigh(weights);
        webmain.wEnterItemName(goodsName);
        webmain.wEnterOrderRemark(remark);
    }
}
